<template>
  <home-card title="权力事项" isDark class="auth-item-wrap">
    <div v-for="task in authList" :key="task.type" class="auth-item">
      <div class="auth-item-title">
        {{ task.title }}
      </div>
      <div class="auth-item-desc">
        <span class="process">{{ getSonNotices(task.sonNoticesList) }}</span>
        <span class="count">({{ task.sonNoticesList.length }})</span>
      </div>
      <!-- <div class="auth-item-auditor">
        <div class="auth-item-avatar">可</div>
        <div class="auth-item-avatar">徐</div>
      </div> -->
      <div class="auth-item-footer">
        <span class="time"
          >{{ parseTime(task.startTime, "{y}/{m}/{d} {h}:{i}")
          }}<br />至&nbsp;{{
            parseTime(task.endTime, "{y}/{m}/{d} {h}:{i}")
          }}</span
        >
        <el-tag class="auth-item-status">进行中</el-tag>
      </div>
    </div>
  </home-card>
</template>

<script>
import { getEnterpriseNotices } from "@/api/home";
import HomeCard from "./home-card.vue";

export default {
  components: { HomeCard },
  data() {
    return {
      authList: [],
    };
  },
  created() {
    this.getListData();
  },
  methods: {
    getListData() {
      getEnterpriseNotices().then((res) => {
        this.authList = res?.data || [];
      });
    },
    getSonNotices(data) {
      return data.map(({ processName }) => processName).join("、");
    },
  },
};
</script>

<style lang="scss" scoped>
.auth-item-wrap {
  max-height: 436px;
  overflow-y: auto;
}
.auth-item {
  padding: 10px;
  background: #fff;
  border-radius: 6px;
  + .auth-item {
    margin-top: 16px;
  }

  &-title {
    font-size: 14px;
    font-weight: 500;
    color: #3f8ff6;
    line-height: 22px;
  }
  &-desc {
    font-size: 12px;
    line-height: 16px;
    margin-top: 10px;
    display: flex;
    align-items: center;

    .process {
      color: #a7aaae;
      display: inline-block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 80%;
      margin-right: 4px;
    }
    .count {
      // font-size: 14px;
      font-weight: bold;
    }
  }
  &-auditor {
    position: relative;
    display: flex;
    margin-top: 20px;

    .auth-item-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: #3f8ff6;
      position: relative;

      border: 2px solid #fff;
      text-align: center;
      color: #fff;
      padding-top: 6px;
      &:not(:first-child) {
        left: -16px;
      }
    }
  }
  &-footer {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .time {
      font-size: 12px;
      color: #a7aaae;
      line-height: 16px;
      width: 130px;
    }
  }
  &-status {
    color: #3772d2;
    background: rgba(55, 114, 210, 0.1);
    border-radius: 4px;
    border: none;
  }
}
</style>
